home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / compress / tar321__.zip / SOURCES.ZIP / LZWBITS.H < prev    next >
C/C++ Source or Header  |  1994-12-31  |  3KB  |  136 lines

  1. /* lzwbits.h */
  2.  
  3. #ifdef pdp11
  4. # define BITS 12    /* max bits/code for 16-bit machine */
  5. # define NO_UCHAR    /* also if "unsigned char" functions as signed char */
  6. #endif
  7.  
  8. #ifdef z8000
  9. # define BITS 12
  10. # undef vax    /* weird preprocessor */
  11. #endif
  12.  
  13. #ifdef __TURBOC__
  14. # ifndef MSDOS
  15. #  define MSDOS
  16. # endif
  17. #endif
  18.  
  19. #ifdef MSDOS
  20. # define BIG
  21. # ifdef BIG        /* then this is a large data compilation */
  22. #  define BITS 16
  23. #  define XENIX_16
  24. # else            /* this is a small model compilation */
  25. #  define BITS 12
  26. # endif
  27. #else
  28. #undef BIG
  29. #endif
  30.  
  31. #ifdef pcxt
  32. # define BITS    12
  33. #endif
  34.  
  35. #ifndef BITS
  36. # define BITS 16    /* Default BITS */
  37. #endif
  38.  
  39. #ifdef M_XENIX
  40. # ifndef i386
  41. #  if BITS >= 16    /* Stupid compiler can't handle arrays with */
  42. #   define XENIX_16    /* more than 65535 bytes - so we fake it */
  43. #  else
  44. #   if BITS > 13    /* Code only handles BITS = 12, 13, or 16 */
  45. #    define BITS 13
  46. #   endif
  47. #  endif
  48. # endif
  49. #endif
  50.  
  51. /* signed compare is slower than unsigned (Perkin-Elmer) */
  52. #ifdef interdata
  53. #    define SIGNED_COMPARE_SLOW
  54. #endif
  55. #ifdef SIGNED_COMPARE_SLOW
  56. #    define to_compare(x) (unsigned)(x)
  57. #else
  58. #    define to_compare(x) (x)
  59. #endif
  60.  
  61. #if BITS == 16
  62. # define _HSIZE    69001L    /* 95% occupancy */
  63. #endif
  64. #if BITS == 15
  65. # define _HSIZE    35023L    /* 94% occupancy */
  66. #endif
  67. #if BITS == 14
  68. # define _HSIZE    18013L    /* 91% occupancy */
  69. #endif
  70. #if BITS == 13
  71. # define _HSIZE    9001L    /* 91% occupancy */
  72. #endif
  73. #if BITS <= 12
  74. # define _HSIZE    5003L    /* 80% occupancy */
  75. #endif
  76.  
  77. /* a code_int must be able to hold 2**BITS values of type int, and also -1 */
  78. #if BITS > 15
  79. #    define code_int long
  80. #else
  81. #    define code_int int
  82. #endif
  83.  
  84. #ifdef SIGNED_COMPARE_SLOW
  85. #    define count_int unsigned long
  86. #else
  87. #    define count_int long
  88. #endif
  89.  
  90. #ifdef NO_UCHAR
  91. #    define char_type char
  92. #    define char_to_byte(x) ((x) & 0xff)
  93. #else
  94. #    define char_type unsigned char
  95. #    define char_to_byte(x) (x)
  96. #endif
  97.  
  98. /* Magic header bytes */
  99. #define LZW_0TH_MAGIC 0x1f
  100. #define LZW_1ST_MAGIC 0x9d
  101. /* Defines for third byte of header */
  102. /* Masks 0x40 and 0x20 are reserved for future. */
  103. #define BIT_MASK   0x1f
  104. #define BLOCK_MASK 0x80
  105. #define INIT_BITS 9 /* initial number of bits/code */
  106.  
  107. #define MAXCODE(n_bits)    (((code_int) 1 << (n_bits)) - 1)
  108.  
  109. #ifdef MSDOS
  110. #    if BITS > 15
  111. #        define ODDBYTES
  112. #    endif
  113. #endif
  114. #ifdef XENIX_16
  115. #    if BITS < 16
  116. #        define PAGEXP 14
  117. #    else
  118. #        ifdef ODDBYTES
  119. #            define PAGEXP 14
  120. #        else
  121. #            define PAGEXP 13
  122. #        endif
  123. #    endif
  124. #    define PAGESIZE (1<<PAGEXP)
  125. #    define PAGEMASK (PAGESIZE-1)
  126. #    define MAXPAGES (int)((_HSIZE+PAGESIZE-1)/PAGESIZE)
  127. #    define NUMPAGES (int)((((code_int)1 << BITS) + PAGESIZE-1)/PAGESIZE)
  128. #endif
  129.  
  130. #define CHECK_GAP 10000 /* ratio check interval */
  131.  
  132. /* the next two codes should not be changed lightly, as they */
  133. /* must not lie within the contiguous general code space.    */
  134. #define FIRST    257    /* first free entry */
  135. #define CLEAR    256    /* table clear output code */
  136.